{extend name="base"}
{block name="main"}
<div class="details">
    <div class="details_operation clearfix">
        <div class="bui_select">
            <input type="button" value="添&nbsp;&nbsp;加" class="add" onclick="add()">
        </div>  
    </div>
    <table class="table" cellspacing="0" cellpadding="0">
        <thead>
            <tr>
                <th width="15%">编号</th>
                <th width="25%">管理员名称</th>
                <th width="30%">管理员邮箱</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {volist name="infoList" id="info"}
                <tr>
                    <td><input type="checkbox" id="c1" class="check"><label for="c1" class="label">{$info.id}</label></td>
                    <td>{$info.username}</td>
                    <td>{$info.email}</td>
                    <td align="center">
                    <input type="button" value="修改" class="btn" onclick="edit({$info.id})">
                    <input type="button" value="删除" class="btn" onclick="del({$info.id})">
                    </td>
                </tr>
            {/volist}
            {gt name="totalPage" value="1"}
                <tr>
                    <td colspan="4">{$page|showpage="$totalPage"}</td>
                </tr>
            {/gt}
        </tbody>
    </table>
</div>
{load href='__PUBLIC__/static/js/jquery-3.1.1.min.js'}
<script type="text/javascript">
    function add(){
        window.location="{:url('admin/admin/add')}";  
    }
    function edit(id){
        window.location="{:url('admin/admin/edit')}?id="+id;
    }
    function del(id){
        if(window.confirm("您确定要删除吗？删除之后不可以恢复哦！！！")){
            $.ajax({
                cache: true,
                type: "GET",
                url : '{:url('admin/admin/delete')}?id='+id,
                data: {'id':id},
                async: false,
                success: function(data) {
                    if (data.code) {
                        alert(data.msg);
                        setTimeout(function () {
                            location.href = data.url;
                        }, 0);
                    } else {
                    alert(data.msg);
                    }
                },
                error: function(request) {
                    alert("页面错误");
                }
            });
        }
    }
</script>
{/block}